package com.myproject.mall.seller.controller;

import com.myproject.mall.common.result.HttpResult;
import com.myproject.mall.domain.dto.ShopDTO;
import com.myproject.mall.domain.entity.Shop;
import com.myproject.mall.domain.vo.ShopVO;
import com.myproject.mall.seller.service.IShopService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Tag(name = "商店接口")
@RestController
@RequestMapping("/api/shop")
@RequiredArgsConstructor
public class ShopController {
    private final IShopService shopService;

    @Operation(summary = "获取商店视图信息")
    @GetMapping("/get/shops")
    public HttpResult<List<ShopVO>> getShops(@RequestParam("ids") List<Long> ids)
    {
        return HttpResult.success(shopService.getShops(ids));
    }

    @Operation(summary = "获取商店信息")
    @GetMapping("/get/info")
    public HttpResult<ShopDTO> getShopInfo(@RequestParam Long id) {
        return HttpResult.success(shopService.getShopInfo(id));
    }


    @Operation(summary = "创建商店")
    @PostMapping("/seller/add")
    public HttpResult<Long> addShop(@RequestBody Shop shop) {
        return HttpResult.success(shopService.addShop( shop));
    }

    @Operation(summary = "更新商店信息")
    @PostMapping("/seller/update")
    public HttpResult<String> updateShop(@RequestBody Shop shop) {
        shopService.updateShop(shop);
        return HttpResult.success("更新完成");
    }

    @Operation(summary = "删除商店")
    @GetMapping("/seller/delete")
    public HttpResult<String> deleteShop(@RequestParam Long id) {
        shopService.deleteShop(id);
        return HttpResult.success("删除完成");
    }

}
